package com.egao.orderB.controller;

import com.egao.common.core.annotation.ApiPageParam;
import com.egao.common.core.annotation.OperLog;
import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.BaseController;
import com.egao.common.core.web.JsonResult;
import com.egao.orderB.entity.Ocean;
import com.egao.orderB.service.OceanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;


/**
 *
 * 订舱管理
 * @author : Doman
 * @date : 2021-09-06 16:20:23
 * @version ：1.0
 */

@Api(tags = "海运订舱管理")
@RestController
@RequestMapping("/api/orderB/ocean")
public class OceanController extends BaseController {

	@Autowired
	private OceanService oceanService;

	/**
	 * 分页查询列表
	 */
	@PreAuthorize("hasAuthority('orderB:ocean:list')")
  @ApiOperation(value ="分页查询订舱管理",notes = "" +
    "limit:每页显示几行 必填\n" +
    "page:第几页 必填\n" +
    "billOfLading:提单号\n" +
    "customer:客户\n" +
    "keywords:状态查询 在某个状态之后的记录都会被查询出来, 比如查放舱, 那么放舱,截单,截关的单子都会被找出来\n" +
    "date1:创建时间开始 格式: 2021-09-08\n" +
    "date2:创建时间结束 格式: 2021-09-08\n" +
    " \n\n\n" +
    "返回的结果:\n" +
    "id:id\n" +
    "preConfigurationId:预配id\n" +
    "customerId:客户Id\n" +
    "customer:客户名称\n" +
    "contacts:联系人\n" +
    "contactsPhone:联系电话\n" +
    "startPort:起运港\n" +
    "endPort:目的港\n" +
    "boxType:箱型\n" +
    "goShipDay:船期\n" +
    "vessel:船名\n" +
    "voyage:航次\n" +
          "airRoute:航线\n" +
    "billOfLading:提单号\n" +
    "bookingAgent:订舱代理\n" +
    "ship:船公司\n" +
    "deliver:发货人\n" +
    "boxNum:箱号\n" +
    "sealno:封号\n" +
    "customerRemark:客户的备注\n" +
    "platRemark:平台备注\n" +
    "financeRemark:财务备注\n" +
    "state:状态:订舱,放舱\n" +
    "bookAnnex:订舱文件\n" +
    "releaseAnnex:放舱文件\n" +
    "cutOffDay:截关日 格式2021-09-01\n" +
    "finishOceanDay:截单日 格式2021-09-01\n" +
    "cutOffAnnex: 截关文件\n" +
    "cusPlanDeposit: 客户计划押金\n" +
    "preStorageDeposit: 预存仓位押金\n" +
    "settlementDate: 结算时间\n" +
    "paymentType: 付款方式: 到付 预付\n" +
    "salesmanId:业务员Id\n" +
    "salesman:业务员\n" +
    "operaterid:操作Id\n" +
    "operater:操作\n" +
    "createTime:创建时间\n" +
    "createUser:创建人\n" +
    "updateTime:更新时间\n" +
    "updateUser:更新人\n" +
    "",httpMethod = "POST")
  @ApiPageParam
  @PostMapping("/list")
  public JsonResult page(PageResult2<T> page, Ocean ocean) throws Exception{
    return oceanService.list(page, ocean, getLoginUser());
  }
	/**
	 * 分页查询列表
	 */
	@PreAuthorize("hasAuthority('orderB:ocean:list')")
  @ApiOperation(value ="分页查询订舱管理 删除列表",notes = "" +
    "limit:每页显示几行 必填\n" +
    "page:第几页 必填\n" +
    "billOfLading:提单号\n" +
    "customer:客户\n" +
    "date1:创建时间开始 格式: 2021-09-08\n" +
    "date2:创建时间结束 格式: 2021-09-08\n" +
    "",httpMethod = "POST")
  @ApiPageParam
  @PostMapping("/listDel")
  public JsonResult listDel(PageResult2<T> page, Ocean ocean) throws Exception{
    return oceanService.listDel(page, ocean, getLoginUser());
  }

  /**
   * 查询全部订舱管理
   */
  @PreAuthorize("hasAuthority('orderB:ocean:list')")
  @ApiOperation("查询全部订舱管理")
  @PostMapping("/listAll")
  public JsonResult list(Ocean ocean){
    return oceanService.list(ocean, getLoginUser());
  }

  @PreAuthorize("hasAuthority('orderB:ocean:list')")
  @PostMapping("/listOpen")
  @ApiOperation(value = "订舱展开查询",notes = "" +
          "id:运单id\n" +
          "\n",httpMethod = "POST")
  public JsonResult listOpen(Ocean ocean, HttpServletRequest request) {
    return oceanService.listOpen(ocean, getLoginUser());
  }

  /**
   * 根据id查询订舱管理
   */
  @PreAuthorize("hasAuthority('orderB:ocean:list')")
  @ApiOperation("根据id查询订舱管理")
  @PostMapping("/get")
  public JsonResult get(Ocean ocean) {
    return oceanService.getById(ocean);
  }

  /**
   * 订舱管理
   */
  @PreAuthorize("hasAuthority('orderB:ocean:save')")
  @OperLog(value = "订舱", desc = "添加", param = false, result = true)
  @ApiOperation(value ="订舱",notes = "" +
    "preConfigurationId:预配id\n" +
    "customerId:客户Id\n" +
    "customer:客户名称\n" +
    "startPort:起运港\n" +
    "endPort:目的港\n" +
    "boxType:箱型\n" +
    "goShipDay:开船日 格式2021-09-01\n" +
    "bookingAgent:订舱代理\n" +
    "ship:船公司\n" +
    "customerRemark:客户的备注\n" +
    "bookAnnex:订舱文件\n" +
          "cusPlanDeposit: 客户计划押金\n" +
          "preStorageDeposit: 预存仓位押金\n" +
    "settlementDate: 结算时间\n" +
    "paymentType: 付款方式: 到付 预付\n" +
    "",httpMethod = "POST")
  @PostMapping("/bookSpace")
  public JsonResult bookSpace(Model model, Ocean ocean, HttpServletRequest request) {
    return oceanService.bookSpace(ocean, getLoginUser(),request);
  }

  /**
   * 放舱管理
   */
  @PreAuthorize("hasAuthority('orderB:ocean:save')")
  @OperLog(value = "放舱", desc = "修改", param = false, result = true)
  @ApiOperation(value ="放舱",notes = "" +
    "id:海运id\n" +
    "vessel:船名\n" +
    "voyage:航次\n" +
    "billOfLading:提单号\n" +
    "releaseAnnex:放舱文件\n" +
    "platRemark:放舱备注\n" +
    "",httpMethod = "POST")
  @PostMapping("/releaseTheCabin")
  public JsonResult releaseTheCabin(Model model, Ocean ocean, HttpServletRequest request) {
    return oceanService.releaseTheCabin(ocean, getLoginUser(),request);
  }

  /**
   * 截关管理
   */
  @PreAuthorize("hasAuthority('orderB:ocean:save')")
  @OperLog(value = "截单", desc = "修改", param = false, result = true)
  @ApiOperation(value ="截单",notes = "" +
    "id:海运id\n" +
    "cutOrderAnnex: 截单文件\n" +
          "finishOceanDay:截单日 格式2021-09-01\n" +
    "",httpMethod = "POST")
  @PostMapping("/cutOrder")
  public JsonResult cutOrder(Model model, Ocean ocean, HttpServletRequest request) {
    return oceanService.cutOrder(ocean, getLoginUser(),request);
  }

  /**
   * 截关管理
   */
  @PreAuthorize("hasAuthority('orderB:ocean:save')")
  @OperLog(value = "截关", desc = "修改", param = false, result = true)
  @ApiOperation(value ="截关",notes = "" +
    "id:海运id\n" +
    "cutOffAnnex: 截关文件\n" +
    "cutOffDay:截关日 格式2021-09-01\n" +
    "",httpMethod = "POST")
  @PostMapping("/cutOff")
  public JsonResult cutOff(Model model, Ocean ocean, HttpServletRequest request) {
    return oceanService.cutOff(ocean, getLoginUser(),request);
  }

  /**
   * 添加订舱管理
   */
//  @PreAuthorize("hasAuthority('orderB:ocean:save')")
//  @OperLog(value = "订舱管理", desc = "添加", param = false, result = true)
//  @ApiOperation(value ="添加订舱管理",notes = "" +
//          "preConfigurationId:预配id\n" +
//    "customerId:客户Id\n" +
//    "customer:客户名称\n" +
//    "contacts:联系人\n" +
//    "contactsPhone:联系电话\n" +
//    "startPort:起运港\n" +
//    "endPort:目的港\n" +
//    "boxType:箱型\n" +
//    "goShipDay:船期\n" +
//    "vessel:船名\n" +
//    "voyage:航次\n" +
//    "billOfLading:提单号\n" +
//    "bookingAgent:订舱代理\n" +
//    "ship:船公司\n" +
//    "deliver:发货人\n" +
//    "boxNum:箱号\n" +
//    "sealno:封号\n" +
//    "customerRemark:客户的备注\n" +
//    "platRemark:平台备注\n" +
//    "financeRemark:财务备注\n" +
//    "state:状态:订舱,放舱\n" +
//    "bookAnnex:订舱文件\n" +
//    "releaseAnnex:放舱文件\n" +
//    "cusPlanDeposit: 客户计划押金\n" +
//    "preStorageDeposit: 预存仓位押金\n" +
//    "settlementDate: 结算时间\n" +
//    "paymentType: 付款方式: 到付 预付\n" +
//    "salesmanId:业务员Id\n" +
//    "salesman:业务员\n" +
//    "operatorId:操作Id\n" +
//    "operator:操作\n" +
//    "",httpMethod = "POST")
//  @PostMapping("/save")
//  public JsonResult save(Model model, Ocean ocean) {
//    return oceanService.save(ocean, getLoginUser());
//  }

  /**
   * 修改订舱管理
   */
  @PreAuthorize("hasAuthority('orderB:ocean:update')")
  @OperLog(value = "订舱管理", desc = "修改", param = false, result = true)
  @ApiOperation(value ="修改订舱管理",notes = "" +
    "id:id\n" +
    "startPort:起运港\n" +
    "endPort:目的港\n" +
    "boxType:箱型\n" +
    "goShipDay:船期 格式2021-09-01\n" +
    "vessel:船名\n" +
    "voyage:航次\n" +
          "airRoute:航线\n" +
    "billOfLading:提单号\n" +
    "bookingAgent:订舱代理\n" +
    "cutOffDay:截关日 格式2021-09-01\n" +
    "finishOceanDay:截单日 格式2021-09-01\n" +
    "ship:船公司\n" +
    "deliver:发货人\n" +
    "boxNum:箱号\n" +
    "sealno:封号\n" +
    "customerRemark:客户的备注\n" +
    "platRemark:平台备注\n" +
    "financeRemark:财务备注\n" +
    "state:状态:订舱,放舱\n" +
    "bookAnnex:订舱文件\n" +
    "releaseAnnex:放舱文件\n" +
          "cusPlanDeposit: 客户计划押金\n" +
          "preStorageDeposit: 预存仓位押金\n" +
    "settlementDate: 结算时间\n" +
    "paymentType: 付款方式: 到付 预付\n" +
    "",httpMethod = "POST")
  @PostMapping("/update")
  public JsonResult update(Model model, Ocean ocean) {
    return oceanService.update(ocean, getLoginUser());
  }

  /**
   * 删除订舱管理
   */
  @PreAuthorize("hasAuthority('orderB:ocean:remove')")
  @OperLog(value = "订舱管理", desc = "删除", result = true)
  @ApiOperation("删除订舱管理")
  @PostMapping("/remove")
  public JsonResult remove(Ocean ocean ) {
    return oceanService.remove(ocean, getLoginUser());
  }


}
